<?php 
class PersonalController extends CommonController{
	
	public function index(){
		//判断是否登陆
		if(!session("uid")){
			go('Index/index');
			
		}
		
		//nav循环
		$nav=$this->nav();
		$this->assign('nav',$nav);
		
		//左侧导航循环
		$Father=$this->cate();
		$this->assign('cate',$Father);
		
		//查询未支付的订单
		
             //总条数
		$allpage=K("Order")->where("user_uid={$_SESSION['uid']} and status='未付款'")->count();
		$this->assign('allpage',$allpage);
		
		//内容
//		$order=K("Order")->where("user_uid={$_SESSION['uid']} and status='未付款'")->all();
//		foreach ($order as $k => $v) {
//			$oid=$v['oid'];
//			$gid=K('Orderlist')->where("order_oid={$oid}")->getField('goods_gid');
//			$order[$k]['pic']=K("Goods")->where("gid={$gid}")->getField('pic');
//			$order[$k]['list']=K('Orderlist')->where("order_oid={$oid}")->all();
//			
//		}
		
//		p($order);
		
		//分页处理
		 $page = new page($allpage,4);// 传入总数 4 
		 $row = K("Order")->where("user_uid={$_SESSION['uid']} and status='未付款'")->limit($page->limit())->all();// 查询当前页的数据 5 
		 foreach ($row as $k => $v) {
			$oid=$v['oid'];
			$gid=K('Orderlist')->where("order_oid={$oid}")->getField('goods_gid');
			$row[$k]['pic']=K("Goods")->where("gid={$gid}")->getField('pic');
			$row[$k]['list']=K('Orderlist')->where("order_oid={$oid}")->all();
			
		}
		 
		 $this->assign('row',$row);
		 
		$this->assign('page',$page->show(3));// 使用第2种栏目显示页码，提供1~5中样式
		
		
		
		$this->display();
	}



    
	public function myorder(){
		
		//nav循环
		$nav=$this->nav();
		$this->assign('nav',$nav);
		
		//左侧导航循环
		$Father=$this->cate();
		$this->assign('cate',$Father);
		
		
		$this->display();		
	}
	
	
	
	
}




 ?>